package com.supermate.init.dto;

import lombok.Data;
import lombok.val;

@Data
public class Result<T> extends BaseRpcResult{

    private T data;

    public static <T> Result<T> success(T data) {
        Result<T> res = new Result();
        res.setData(data);
        res.setIfSuccess(true);
        return res;
    }

    public static Result<Void> fail(String errMsg) {
        Result<Void> res = new Result<Void>();
        res.setIfSuccess(false);
        res.setErrMsg(errMsg);
        return res;
    }

    public static Result fail(String errCode, String errMsg) {
        Result res = fail(errMsg);
        res.setErrCode(errCode);
        return res;
    }

}
